package com.sky.controller.admin;

import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import com.sky.vo.SetmealVO;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/setmeal")
public class SetmealDishController {

    @Autowired
    SetmealService setmealService;
    @PostMapping
    public Result add(@RequestBody SetmealDTO setmealDTO){
        return setmealService.add(setmealDTO);
    }

    @GetMapping("/page")
    public Result page( SetmealPageQueryDTO setmealPageQueryDTO){
        PageResult page = setmealService.page(setmealPageQueryDTO);
        return Result.success(page);
    }

    @GetMapping("/{id}")
    public Result getById(@PathVariable Long id){
        Result byId = setmealService.getById(id);
        return byId;
    }

    @PutMapping
    public Result update(@RequestBody SetmealVO setmealVO){
        Result update = setmealService.update(setmealVO);
        return update;
    }

    @DeleteMapping
    public Result deleteById(@RequestParam List<Long> ids){
        return setmealService.deleteById(ids);
    }
    //status/1?id=32

    @PostMapping("/status/{status}")
    public Result updateStatus(@PathVariable Integer status,Long id){
        return setmealService.updateStatus(status,id);
    }

}
